package model
{
	import fl.transitions.Tween;
	import fl.transitions.easing.*;
	import flash.net.URLRequest;
	

	public class Question
	{
		import flash.media.*;
		
		private var rightProducts:Array = new Array();
		private var wrongProducts:Array = new Array();
		private var id:String = new String();
		private var level:uint = new uint();
		private var questionSound:Sound = new Sound();
		
		public function Question(level:uint):void
		{
			this.level = level;
			this.init();
		}
	
		//parse xml and get question as well as belonging products for givin level
		public function init():void
		{
			//mock data
			this.id = "gemuese";
			this.questionSound.load(new URLRequest(Config.ProductSoundPath + "tmp.mp3"));
			rightProducts.push(new Product("right-" + 0,
				Config.ProductPicPath + "Ananas.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			rightProducts.push(new Product("right-" + 1,
				Config.ProductPicPath + "Apfel.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			rightProducts.push(new Product("right-" + 2,
				Config.ProductPicPath + "Banane.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			rightProducts.push(new Product("right-" + 3,
				Config.ProductPicPath + "Brombeeren.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			rightProducts.push(new Product("right-" + 4,
				Config.ProductPicPath + "Orange.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			
			wrongProducts.push(new Product("false-" + 0,
				Config.ProductPicPath + "Blumenkohl.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 1,
				Config.ProductPicPath + "Margarine.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 2,
				Config.ProductPicPath + "Bratwurst.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 3,
				Config.ProductPicPath + "Champignons.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 4,
				Config.ProductPicPath + "Erbsen.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 5,
				Config.ProductPicPath + "Gewuerzgurken.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 6,
				Config.ProductPicPath + "Kiwi.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 7,
				Config.ProductPicPath + "Karotten.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 8,
				Config.ProductPicPath + "Kartoffel.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 9,
				Config.ProductPicPath + "Knoblauch.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 10,
				Config.ProductPicPath + "Kohlrabi.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 11,
				Config.ProductPicPath + "Bohnen.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
			
			wrongProducts.push(new Product("false-" + 12,
				Config.ProductPicPath + "Kloesse.png",
				Config.ProductSoundPath + "tmp.mp3",
				Config.ProductSoundPath + "tmp.mp3"));
		/*	for(var i:uint=0;i<Config.RightProductsPerLevel;i++) {
				this.rightProducts.push(
					new Product(
						"right-" + i,
						Config.ProductPicPath + "Mehl.png",
						Config.ProductSoundPath + "Mehl.mp3",
						Config.ProductSoundPath + "Mehl.mp3"
					)
				);
			}
			for(var j:uint=0;j<Config.WrongProductsPerLevel;j++) {
				this.wrongProducts.push(
					new Product(
						"wrong-" + j,
						Config.ProductPicPath + "Mehl.png",
						Config.ProductSoundPath + "Mehl.mp3",
						Config.ProductSoundPath + "Mehl.mp3"
					)
				);
			}*/			
		}
		
		public function getProducts():Array
		{
			var tween:Tween = new Tween(rightProducts[1], "x", Strong.easeOut, 300, 600, 4, true);
			return this.rightProducts.concat(this.wrongProducts);
		}
		
		/**
		 * Speichert das Array mit den 5 richtigen Produkten
		 */
		public function setRightProducts(rightProducts:Array):void
		{
			this.rightProducts = rightProducts;
		}
		
		/**
		 * Speichert das Array mit den 10 richtigen Produkten
		 */
		public function setWrongProducts(wrongProducts:Array):void
		{
			this.wrongProducts = wrongProducts;
		}
		
		/**
		 * Speichert das Sound-Objekt der Fragestellung
		 */
		public function setQuestionSound(questionSound:Sound):void
		{
			this.questionSound = questionSound;
		}
		
		/**
		 * Speichert die questionID
		 */
		public function setQuestionID(questionID:String):void
		{
			this.id=questionID;
		}
	}
}